<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CategoryArtcile extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        //文章分类表
        Schema::create('article_category', function (Blueprint $table) {
            $table->increments('id');
            $table->string('name',30)->comment('分类名称');
            $table->integer('pid')->nullable()->default(0)->comment('父级id');
            $table->timestamps();
        });

        //文章表
        Schema::create('article', function(Blueprint $table){
            $table->increments('id');
            $table->integer('cate_id')->comment('分类id');
            $table->string('title',50)->comment('文章标题');
            $table->string('description',120)->nullable()->comment('文章描述');
            $table->text('content')->nullable()->comment('文章内容');
            $table->integer('views')->nullable()->default(0)->comment('流浪量');
            $table->string('author',15)->nullable()->comment('文章作者');
            $table->string('from',150)->nullable()->comment('来源哪里');
            $table->timestamps();
            //索引
            $table->index('cate_id','_cate_id');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('article');
        Schema::dropIfExists('article_category');
    }
}
